Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FSSDK-10265] fix: UPS Lookup & Save during batched Decide #374

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

mikechu-optimizely
Copy link
Contributor

Summary

  • User Profile Service should only Lookup and Save once when using DecideAll and DecideForKeys.

Test plan

  • Existing and new unit tests should pass
  • FSC should pass

Issues

  • FSSDK-10265

@mikechu-optimizely mikechu-optimizely marked this pull request as ready for review October 8, 2024 20:04
@mikechu-optimizely mikechu-optimizely requested a review from a team as a code owner October 8, 2024 20:04
@mikechu-optimizely mikechu-optimizely changed the title [FSSDK-10265] ups during batch decide [FSSDK-10265] fix: UPS Lookup & Save during batched Decide Oct 8, 2024
Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good!
I have a couple of suggestions for legacy API support and testing.

Comment on lines +517 to +519
private void SaveToUserProfileService(Experiment experiment = null,
Variation variation = null
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about making experiment and variation NonNull and drop ?
I see this will be called only when a new decision is made.

var userProfileMap = UserProfileService.Lookup(user.GetUserId());
if (userProfileMap != null &&
UserProfileUtil.IsValidUserProfileMap(userProfileMap))
if (_userProfile == null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For legacy, we need to load fresh _userProfile on every getVariation() call (even if _userProfile not null)

@@ -1066,6 +1067,8 @@ OptimizelyDecideOption[] options
}
}

DecisionService.DecisionBatchInProgress = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this will fire the saveUPS. Wondering if we have the similar fire solution for legacy APIs (activate, getVarition)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this comment not pushed properly:

We probably need one more test -
decide(A)
decide(B)
2nd session picks up the UPS as expected

OptimizelySDK.Tests/OptimizelyUserContextTest.cs Outdated Show resolved Hide resolved
userProfileServiceMock.Verify(l => l.Save(It.IsAny<Dictionary<string, object>>()),
Times.Once);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests look good. Wondering if we have tests covering the contents of the final UPS save call, combining all decisions in the session.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also have the similar coverage (lookup once - save once, the ups save contents) with legacy APIs (activate, getVariation) for regression?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added coverage of the final UPS Save as requested.

I'm researching the Activate and GetVariation tests where UPS is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants